package logic

import (
	"B/models/mysql"
	"context"

	"B/internal/svc"
	"B/shenzhousrv"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserListLogic {
	return &UserListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserListLogic) UserList(in *shenzhousrv.UserListRequest) (*shenzhousrv.UserListResponse, error) {
	// todo: add your logic here and delete this line
	var users []mysql.User
	mysql.DB.Debug().Where("status = ?", in.Status).Find(&users)
	var lists []*shenzhousrv.UserList
	for _, v := range users {
		lists = append(lists, &shenzhousrv.UserList{
			UserId: int64(v.ID),
			Phone:  v.Phone,
			Status: int64(v.Status),
		})
	}
	return &shenzhousrv.UserListResponse{
		List: lists,
	}, nil
}
